PROJECT(IO_Slave_CDLL)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

SET(CMAKE_BUILD_TYPE Debug)  # Release
# SET(CMAKE_C_FLAGS "-Wall -std=c11")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -O0 -g -ggdb")
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O3")

# SET(CMAKE_CXX_FLAGS "-Wall -std=c++11")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -g -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3")
# SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/tbin)
# SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/tlib)
SET(LIBRARY_OUTPUT_PATH ../..)

# 包含外部头文件目录
SET(INC_DIRS 
	./
	$ENV{NUTHOME}/include/
	$ENV{NUTHOME}/include/usint/
	$ENV{NUTHOME}/include/ragbear/
	$ENV{NUTHOME}/include/hal/
	)
FOREACH(INC_DIR ${INC_DIRS})
	INCLUDE_DIRECTORIES(${INC_DIR})
	AUX_SOURCE_DIRECTORY(${INC_DIR} SRC_FILES_CDLL)
ENDFOREACH()

# 添加外部库文件目录(FIND_LIBRARY is better)
LINK_DIRECTORIES(
	$ENV{NUTHOME}/lib/
	)

ADD_LIBRARY(ioslave SHARED ${SRC_FILES_CDLL})

SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
# SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)

TARGET_LINK_LIBRARIES(ioslave
	nutaccess  userkit
	)

SET(CMAKE_INSTALL_PREFIX $ENV{HOME}/local)
# INSTALL(TARGETS  __2__
# 		RUNTIME DESTINATION bin
# 		LIBRARY DESTINATION lib
# 		ARCHIVE DESTINATION lib)
#INSTALL(FILES  ***  DESTINATION  <dir>)
#INSTALL(PROGRAMS  ***  DESTINATION  <dir>)
#INSTALL(DIRECTORY  ***  DESTINATION  <dir>)
